<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('修改鸡出库')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-ncOutputChicken-edit" th:object="${ncOutputChicken}">
            <input id="outputId" name="outputId" th:field="*{outputId}"  type="hidden">
			<input id="cforderId" name="cforderId" th:field="*{cforderId}"  type="hidden">
			<!--<div class="form-group">
				<label class="col-sm-3 control-label">菜房订单id：</label>
				<div class="col-sm-8">
					<input id="cforderId" name="cforderId" th:field="*{cforderId}" class="form-control" type="text">
				</div>
			</div>-->
			<!--<div class="form-group">
				<label class="col-sm-3 control-label">出库日期：</label>
				<div class="col-sm-8">
					<input type="text" style="height: 34px;" data-format="yyyy-MM-dd HH:mm:ss"  th:value="*{#dates.format(outputTime, 'yyyy-MM-dd HH:mm:ss')}" data-type="datetime" name="outputTime" class="time-input" id="outputTime" />
				</div>
			</div>-->
			<div class="form-group">
				<label class="col-sm-3 control-label">库存：</label>
				<div class="col-sm-8">
					<select name="inputId" id="inputId" class="form-control m-b">
						<option th:each="chicken:${inputChicken}" th:amount="${chicken.stackAmount}" th:value="${chicken.inputId}" th:text="${chicken.inputCode} +'鸡' +'-('+${chicken.stackAmount}+')只'"></option>
					</select>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">需求数量（只）：</label>
				<div class="col-sm-8">
					<input id="requestAmount" name="requestAmount" th:field="*{requestAmount}" class="form-control" type="number" onkeyup=" value=value.replace(/^(0+)|[^\d]+/g,'')" min="0" required>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">供应数量（只）：</label>
				<div class="col-sm-8">
					<input id="outputAmount" name="outputAmount" th:field="*{outputAmount}" class="form-control" type="number"  onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')" min="0" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">供应大鸡数量（只）：</label>
				<div class="col-sm-8">
					<input id="outputAmountBig" name="outputAmountBig" th:field="*{outputAmountBig}" class="form-control" type="number"  onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')" min="0">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">供应小鸡数量（只）：</label>
				<div class="col-sm-8">
					<input id="outputAmountLittle" name="outputAmountLittle" th:field="*{outputAmountLittle}" class="form-control" type="number"  onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')" min="0">
				</div>
			</div>
			<!--
			<div class="form-group">	
				<label class="col-sm-3 control-label">出库类型：</label>
				<div class="col-sm-8">
					<select name="outputType" required class="form-control m-b" th:with="type=${@dict.getType('outputType')}">
						<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{outputType}"></option>
					</select>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">抓鸡时间：</label>
				<div class="col-sm-8">
					<input type="text" style="height: 34px;" data-format="yyyy-MM-dd HH:mm:ss"  th:value="*{#dates.format(catchTime, 'yyyy-MM-dd HH:mm:ss')}" data-type="datetime" name="catchTime" class="time-input" id="catchTime"/>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">母鸡状态：</label>
				<div class="col-sm-8">
					<select name="chickenStatus" required class="form-control m-b" th:with="type=${@dict.getType('chickenStatus')}">
						<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{chickenStatus}" ></option>
					</select>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">宰杀时间：</label>
				<div class="col-sm-8">
					<input type="text" style="height: 34px;" data-format="yyyy-MM-dd HH:mm:ss"  th:value="*{#dates.format(killTime, 'yyyy-MM-dd HH:mm:ss')}" data-type="datetime" name="killTime" class="time-input" id="killTime"/>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">宰杀后成品母鸡标准：</label>
				<div class="col-sm-8">
					<select name="isHealthy" required class="form-control m-b" th:with="type=${@dict.getType('isHealthy')}">
						<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{isHealthy}"></option>
					</select>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">宰杀人员：</label>
				<div class="col-sm-8">
					<input id="butcher" name="butcher" th:field="*{butcher}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">菜房接收时间：</label>
				<div class="col-sm-8">
					<input type="text" style="height: 34px;" data-format="yyyy-MM-dd HH:mm:ss"  th:value="*{#dates.format(receiveTime, 'yyyy-MM-dd HH:mm:ss')}" data-type="datetime" name="receiveTime" class="time-input" id="receiveTime"/>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">菜房接收人员：</label>
				<div class="col-sm-8">
					<input id="receiver" name="receiver" th:field="*{receiver}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">出库经手人：</label>
				<div class="col-sm-8">
					<input id="outputUser" name="outputUser" th:field="*{outputUser}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">创建者：</label>
				<div class="col-sm-8">
					<input id="createBy" name="createBy" th:field="*{createBy}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">创建时间：</label>
				<div class="col-sm-8">
					<input id="createTime" name="createTime" th:field="*{createTime}" class="form-control" type="text">
				</div>
			</div>-->
			<div class="form-group">	
				<label class="col-sm-3 control-label">备注：</label>
				<div class="col-sm-8">
					<textarea id="remark" name="remark" th:field="*{remark}" class="form-control" type="text"></textarea>
				</div>
			</div>
		</form>
    </div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		var prefix = ctx + "system/ncOutputChicken";
		$("#form-ncOutputChicken-edit").validate({
			rules:{
				xxxx:{
					required:true,
				},
			},
			focusCleanup: true
		});
		
		function submitHandler() {
            var outputAmount=$("#outputAmount").val();
            var inputamount=$('#inputId').find("option:selected").attr("amount");
            if(parseInt(outputAmount) > parseInt(inputamount)){
                $.modal.alertWarning("所选批次库存不足！");
            }
            else if($("#outputAmountBig").val() != '' || $("#outputAmountLittle").val() != ''){
                if((parseInt($("#outputAmountBig").val())+parseInt($("#outputAmountLittle").val())) != parseInt(outputAmount)){
                    $.modal.alertWarning("大小鸡数量之和要与供应数量一致！");
                }
                else{
                    if ($.validate.form()) {
                        $.operate.save(prefix + "/edit", $('#form-ncOutputChicken-edit').serialize());
                    }
				}
            }
            else{
	        	if ($.validate.form()) {
	            	$.operate.save(prefix + "/edit", $('#form-ncOutputChicken-edit').serialize());
	        	}
            }
	    }
	</script>
</body>
</html>
